<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
  String path = request.getContextPath();
  String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
  String _id=request.getParameter("_");
%>
<p id="category" style="display: none">${category}</p>
<div class="jqGrid_wrapper">
  <table id="dialog_asset_table"></table>
  <div id="dialog_asset_page"></div>
</div>

<script>

  $(function(){
    // 加载数据
    init_grid_dialog_asset();
  });

  // 初始化表单数据
  function init_grid_dialog_asset() {
    var cat = parseInt($("#category").text());
    __init_jqgrid('dialog_asset_table', 'dialog_asset_page',
            '<%=path%>/com/asset/list',
            ['固定资产编号', '资产名称','品牌','规格型号','使用部门','使用人','采购金额（元）','采购日期', 'id'],
            [
              {name: 'assetNo', index: 'assetNo', width: 160, sortable: false, stype: 'text', searchoptions: {sopt: ['cn']}},
              {name: 'name', index: 'name', width: 160, sortable: false, stype: 'text', searchoptions: {sopt: ['cn']}},
                {name: 'brand', index: 'brand', width: 100,  hidden: true, hidedlg: true},
                {name: 'model', index: 'model', width: 100, hidden: true, hidedlg: true},
                {name: 'userDept', index: 'userDept', width: 40, hidden: true, hidedlg: true},
                {name: 'userName', index: 'userName', width: 40, hidden: true, hidedlg: true},
                {name: 'purchaseMoney', index: 'purchaseMoney', width: 40, hidden: true, hidedlg: true},
                {name: 'datPurchase', index: 'datPurchase', width: 40, hidden: true, hidedlg: true},
              {name: 'id', index: 'id', width: 100, key: true, hidden: true, hidedlg: true}
            ],
            true,
            {
                multiselect: false,
                autowidth: false,
                width: 558,
                postData: {viewtype: cat}
            }
    )

  }

  function fn_dialog_asset_select(callback) {
      var rowId = $('#dialog_asset_table').jqGrid('getGridParam', 'selrow');
      if (rowId) {
          callback($('#dialog_asset_table').jqGrid('getRowData', rowId));
      } else {
          __toastr_warning('请至少选择一个资产');
          callback();
      }
  }

</script>